<template>
  <div class="cent" id="setH" :class="{'English':languageData.id == 'English'}">
    <p class="isCollapse el-icon-more"  @click="isCollapse= !isCollapse"></p>
    <el-menu :default-active="$route.path"  :router="true" background-color="#545c64" text-color="#fff"   active-text-color="#ffd04b" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
      <el-menu-item index="/CompanyProfile" v-show ='user.type==0'>
        <i class="el-icon-menu"></i>
        <router-link to="/CompanyProfile"><span style="color: #fff">企业管理</span></router-link>
      </el-menu-item>
      <el-menu-item index="/BusinessConfig" v-show ='user.type==0'>
        <i class="el-icon-news"></i>
        <router-link to="/BusinessConfig"><span style="color: #fff">业务管理</span></router-link>
      </el-menu-item>
      <el-menu-item index="/nwes" v-show ='user.type==0'>
        <i class="el-icon-document"></i>
        <router-link to="/nwes"><span style="color: #fff">新闻管理</span></router-link>
      </el-menu-item>
      <el-menu-item index="/AdminOderList" >
        <i class="el-icon-location"></i>
        <router-link to="/AdminOderList"><span style="color: #fff">询价单</span></router-link>
      </el-menu-item>
      <!--<el-submenu index="/adminchart">-->
        <!--<template slot="title" >-->
          <!--<i class="el-icon-location"></i>-->
          <!--<router-link to="/AdminOderList"><span  style="color: #fff">询价单</span></router-link>-->
        <!--</template>-->
        <!--&lt;!&ndash;<el-menu-item-group>&ndash;&gt;-->
          <!--&lt;!&ndash;<el-menu-item index="/adminchart/ment">&ndash;&gt;-->
            <!--&lt;!&ndash;<router-link to="/BusinessConfig"><span style="color: #fff">菜单配置</span></router-link>&ndash;&gt;-->
          <!--&lt;!&ndash;</el-menu-item>&ndash;&gt;-->
          <!--&lt;!&ndash;<el-menu-item index="/adminchart/Bananer">&ndash;&gt;-->
            <!--&lt;!&ndash;<router-link to="/BusinessConfig"><span style="color: #fff"> banner配置</span></router-link>&ndash;&gt;-->
           <!--&lt;!&ndash;</el-menu-item>&ndash;&gt;-->
        <!--&lt;!&ndash;</el-menu-item-group>&ndash;&gt;-->
      <!--</el-submenu>-->
    </el-menu>
  </div>
</template>
<style scoped>
.isCollapse{width:100%;text-align: center;background: #545c64;color: #fff;height: 40px;border-bottom:1px solid #e1e1e1;font-size: 18px;line-height:  40px}
.cent{text-align: left;line-height: 0rem}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
  text-align: left;
  border: 0px none;
}
 .el-menu-vertical-demo{
   border: 0px none;
 }
</style>
<script>
  import { mapState, mapActions } from 'vuex'
  import HeaderPublc from './herder.vue'
  import Public from '../../vuex/public.js'
  // import UserImgIcon_sel from '../../../static/img/icon/icon_yhgl_sel.png'
  // import UserImgIcon from '../../../static/img/icon/icon_yhgl_nor.png'
  // import DevisIcon from '../../../static/img/icon/icon_sbgl_nor.png'
  // import DevisIcon_sel from '../../../static/img/icon/icon_sbgl_sel.png'
  // import UserImg from '../../../static/img/icon/userDeFilt.png'
  // import UserImgAad from '../../../static/img/icon/icon_cjyh_nor.png'
  // import UserImgAad_sel from '../../../static/img/icon/icon_cjyh_sel.png'
  // import CityImgAdd from '../../../static/img/icon/icon_cssz_nor.png'
  // import CityImgAdd_sel from '../../../static/img/icon/icon_cssz_sel.png'
  export default {
    name: 'my-set',
    created () {
      // 查看本页面路由 绑定对应页面class
      this.checktext  = this.$route.name
      var usr = sessionStorage.getItem('user')

      if(usr) {
        usr = JSON.parse(usr)
        if(!usr.userId){
          this.$router.push({ name: 'index' })
        }
        if(usr.type == 1 && this.checktext == 'AdminConfig'){
         // this.$router.push({ name: 'adminDavise' })
        }
        if(usr.type == 1 && this.checktext == 'adminAddUser'){
         // this.$router.push({ name: 'adminDavise' })
        }
        if(usr.type == 0 && this.checktext == 'adminDavise'){
         // this.$router.push({ name: 'AdminConfig' })
        }
        if(usr.type == 0 && this.checktext == 'cityConfig'){
         // this.$router.push({ name: 'AdminConfig' })
        }
        this.user.name = usr.userName
        this.user.type = usr.type
        this.user.userId = usr.userId
      }else {
        //this.$router.push({ name: 'login' })
      }
      if(this.checktext == 'AdminConfig'){
        // this.userImgIcon = UserImgIcon_sel
      }
      if(this.checktext == 'adminDavise'){
       // this.devisIcon = DevisIcon_sel
      }
      if(this.checktext == 'adminAddUser'){
        //this.userImgAad = UserImgAad_sel
      }
      if(this.checktext == 'cityConfig'){
       // this.cityImgAdd = CityImgAdd_sel
      }
    },
    data () {
      return {
        isCollapse: false,
        activeIndex: '1',
        user:{}
      }
    },
    methods: {
      ...mapActions({
        lognOutPost: 'loginOutFn'
      }),
      login () {
        this.$router.push({ name: "map" })
      },
      goConfig () {
        this.$router.push({ name: 'AdminConfig' })
      },
      goDavise (tex) {
        this.$router.push({ name: tex })
      },
      // 退出登陆
      loginOut (id) {
       // this.show2 = !this.show2
        if(id){
          this.$router.push({ name: 'chart' })
        }else {
          var parm = {
            userId: this.user.id
          }
          this.lognOutPost(parm)
          Public.publicLo.sessionStorageSav('token', '')
          Public.publicLo.sessionStorageSav('user', '')
          // 清空所有数据
          this.$store.commit('loginOut', null)
          this.$router.push({ name: 'login' })
        }
        },
      handleOpen(key, keyPath) {

      },
      handleClose(key, keyPath) {

      }
    },
    computed: {
      languageData: function () {
        var parm = this.language
        if (parm) {

          if (parm.check == 'Chinese') {
            parm = parm.Chinese
          }
          if (parm.check == 'English') {
            parm = parm.English
//            dom.style = 'width:620px'
          }
//
//          // 替换 其他交互数据
//          this.updateDate(parm)
        }
        return parm
      },
      updateStatusData: function () {
        var parm = this.updateStatus
        if (parm == 'out') {
          // 没记住密码保存空 localStorage
          Public.publicLo.sessionStorageSav('token', '')
          Public.publicLo.sessionStorageSav('user', '')
          // 清空所有数据
          this.$store.commit('loginOut', null)
          this.$router.push({ name: 'login' })
          // this.lognOutPost(this.user)
        } else if (parm == 'outErorr') {
          Public.publicLo.sessionStorageSav('token', '')
          Public.publicLo.sessionStorageSav('user', '')
          // 清空所有数据
          this.$store.commit('loginOut', null)
          this.$router.push({ name: 'login' })
        }
        return 1
      },
      ...mapState([
        'nav',
        'language',
        'updateStatus'
      ])
    },
    mounted () {
      // 配置顶部菜单
      var dom = document.body.clientHeight
      var dom2 = document.body.clientHeight

      if(dom<dom2){
        dom =dom2
      }
      document.getElementById('setH').style='height:'+dom+'px;width:200px'
      // setTimeout(function () {
      //
      // },0)

    },
    components: {
       HeaderPublc: HeaderPublc
    }
  }
</script>

